//
//  AppDelegate.swift
//  NetCheck
//
//  Created by 郑东喜 on 2016/11/25.
//  Copyright © 2016年 郑东喜. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        
        // 创建window
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = ViewController2()
        window?.makeKeyAndVisible()
        
        self.chrcm()
        
        return true
    }

}

extension AppDelegate {
    func chrcm() -> Void {
        CheckTool.shared.check { (netStatus) in
            print("工具类检测",netStatus)
            
            if netStatus == "No Connection" {
                let alertController = UIAlertController.init(title: "提示", message: "网络连接失败", preferredStyle: .alert)
                
                alertController.addAction(UIAlertAction.init(title: "确定", style: .destructive, handler: nil))
                UIApplication.shared.keyWindow?.rootViewController?.present(alertController, animated: true, completion: nil)
            }
        }
    }
}

